unit PlatSum;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  EntryDlg, StdCtrls, Mask, ToolEdit, CurrEdit;

type
  TfmPlatSum = class(TfmEntryDlg)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    lblCount: TLabel;
    lblSum: TLabel;
    edtGotSum: TCurrencyEdit;
    lblSdacha: TLabel;
    btnOk: TButton;
    procedure FormShow(Sender: TObject);
    procedure edtGotSumExit(Sender: TObject);
  private
    { Private declarations }
    FSum: currency;
    procedure ShowSdacha;
  public
    { Public declarations }
  end;

var
  fmPlatSum: TfmPlatSum;

implementation
uses DM;
{$R *.DFM}

procedure TfmPlatSum.FormShow(Sender: TObject);
begin
  inherited;
  lblCount.Caption := IntToStr(Marks.Count);
  FSum := Marks.GetTotal;
  lblSum.Caption := FormatCurr('#,###,###,##0.00', FSum);
  edtGotSum.Value := 0;
  ShowSdacha;
end;

procedure TfmPlatSum.ShowSdacha;
var v: currency;
begin
  v := edtGotSum.Value - FSum;
  if v >= 0 then
    lblSdacha.Font.Color := clBlack
  else
    lblSdacha.Font.Color := clRed;
  lblSdacha.Caption := FormatCurr('#,###,###,##0.00', v);
end;

procedure TfmPlatSum.edtGotSumExit(Sender: TObject);
begin
  inherited;
  ShowSdacha;
end;

end.
